-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EZP-29089: Usability bug when deleting containers #704
EZP-29089: Usability bug when deleting containers #704
Conversation
This comment has been minimized.
This comment has been minimized.
}; | ||
|
||
toggleForm.addEventListener('submit', openTrashImageAssetModal, false); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed empty line
{ | ||
$children = $this->locationService->loadLocationChildren($item); | ||
|
||
return 0 !== $children->totalCount; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe 0 < $children->totalCount
@@ -0,0 +1,17 @@ | |||
(function (global, doc) { | |||
const toggleForm = doc.querySelector('form[name="location_trash_container"]'); | |||
const haveAsset = toggleForm.dataset.haveAsset; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hasAsset
(function (global, doc) { | ||
const toggleForm = doc.querySelector('form[name="location_trash_container"]'); | ||
const haveAsset = toggleForm.dataset.haveAsset; | ||
const haveUniqueAsset = toggleForm.dataset.haveUniqueAsset; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hasUniqueAsset
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we not be consistent with how the corresponding class is named?
@@ -0,0 +1,27 @@ | |||
(function (global, doc) { | |||
const toggleForms = [...doc.querySelectorAll('.ez-toggle-btn-state-checkbox')]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Due to latest changes in the browsers specification implementation, doc.querySelectorAll('.ez-toggle-btn-state-checkbox')
is just enough. No need to convert it to an array to use with forEach
only.
const ANY_CHECKED = 'any-checked'; | ||
|
||
toggleForms.forEach((toggleForm) => { | ||
const checkboxInputs = [...toggleForm.querySelectorAll('input[type="checkbox"]')]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
|
||
toggleForms.forEach((toggleForm) => { | ||
const checkboxInputs = [...toggleForm.querySelectorAll('input[type="checkbox"]')]; | ||
const toggleButtonState = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function should be implemented outside of forEach
loop. If you want to have an access to the checkboxInputs
then a useful piece of information is that a forEach
loop callback takes 3 params: item, index, an iterated array with all values. See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach
const toggleButtonState = () => { | ||
const button = doc.querySelector(toggleForm.dataset.toggleButtonId); | ||
|
||
const anyIsChecked = checkboxInputs.some(el => el.checked); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CS: all variables should come one after another without additional empty lines between them.
{{ form_widget(form.trashContainer) }} | ||
</div> | ||
<div class="modal-footer"> | ||
<button type="button" class="btn btn-secondary btn--no" data-dismiss="modal"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to our style guidelines (https://doc.ezplatform.com/en/2.2/guidelines/components/buttons/) this button probably should have classes btn btn-dark
.
|
||
const toggleButtonState = (toggleForm, checkboxInputs) => { | ||
const button = doc.querySelector(toggleForm.dataset.toggleButtonId); | ||
const anyIsChecked = checkboxInputs.some(el => el.checked); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isAnyChecked
const checkboxInputs = toggleForm.querySelectorAll('input[type="checkbox"]'); | ||
|
||
checkboxInputs.forEach((input, index, inputs) => { | ||
input.addEventListener('change', toggleButtonState.bind(null, toggleForm, [...inputs]), false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need [...inputs]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't use .some
and .every
on Node Collection, unless there is some other way to do this.
const toggleButtonState = (toggleForm, checkboxInputs) => { | ||
const button = doc.querySelector(toggleForm.dataset.toggleButtonId); | ||
const anyIsChecked = checkboxInputs.some(el => el.checked); | ||
const allChecked = checkboxInputs.every(el => el.checked); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this line and the line above can be moved into the line line no. 22 and 23, for better performance.
@mnocon Behat is failing here |
Perhaps rebase is needed with master after your fix will be merged up. |
@ViniTou could you rebase with master? |
Description
This checks if location is non-empty container and if it is displays additional info modal. If content have asset fieldtype additional modals are displayed after first one.
Checklist:
$ composer fix-cs
)